using AiQiuQuan.Sport.Model.Models;
using AiQiuQuan.Sport.Core;
using AiQiuQuan.Sport.WebApi.Services;
using Microsoft.AspNetCore.Mvc;

namespace AiQiuQuan.Sport.WebApi.Controllers
{
    /// <summary>
    /// 平台活动管理
    /// </summary>
    public class PlatformActivityController : PcApiController
    {
        private readonly IActivityService _activityService;

        /// <summary>
        /// ctor
        /// </summary>
        public PlatformActivityController(
            IActivityService activityService
            )
        {
            _activityService = activityService;
        }

        /// <summary>
        /// 查询一条记录
        /// </summary>
        [HttpGet("get")]
        public async Task<UnaryResult<ActivityDto>> GetAsync(Guid id)
        {
            var result = await _activityService.GetAsync(id);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 活动查询
        /// </summary>
        [HttpPost("query")]
        public async Task<UnaryResult<ActivityDto>> QueryAsync(ActivitDetailRequestDto request)
        {
            var result = await _activityService.QueryAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 活动分页查询
        /// </summary>
        [HttpPost("pagelist")]
        public async Task<UnaryResult<PageResult<ActivityDto>>> PageListAsync(ActivityPageReqestDto request)
        {
            var result = await _activityService.PageListAsync(request);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 活动新增
        /// </summary>
        [HttpPost("add")]
        public async Task<UnaryResult> AddAsync(ActivityAddDto model)
        {
            var result = await _activityService.AddAsync(model);
            return result;
        }

        /// <summary>
        /// 活动修改
        /// </summary>
        [HttpPost("update")]
        public async Task<UnaryResult> UpdateAsync(ActivityUpdateDto model)
        {
            var result = await _activityService.UpdateAsync(model);
            return result;
        }

        /// <summary>
        /// 活动修改状态
        /// </summary>
        [HttpPost("update_state")]
        public async Task<UnaryResult> UpdateStateAsync(ActivityStateUpdateDto model)
        {
            var result = await _activityService.UpdateStateAsync(model);
            return result;
        }

        /// <summary>
        ///  活动删除
        /// </summary>
        /// <param name="id">活动ID</param>
        [HttpPost("delete")]
        public async Task<UnaryResult> DeleteAsync(Guid id)
        {
            var result = await _activityService.DeleteAsync(id);
            return result;
        }

        /// <summary>
        /// 活动用户列表查询
        /// </summary>
        /// <param name="activityId">活动ID</param>
        [HttpGet("get_user_list")]
        public async Task<UnaryResult<List<ActivityUserSimpleDto>>> QueryActivityUserListAsync(Guid activityId)
        {
            var result = await _activityService.QueryActivityUserListAsync(activityId);
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 活动用户列表查询 订单ID
        /// </summary>
        /// <param name="orderId">订单ID</param>
        [HttpGet("get_user_list_by_orderid")]
        public async Task<UnaryResult<List<ActivityUserSimpleDto>>> QueryActivityUserListByOrderIdAsync(Guid orderId)
        {
            var result = await _activityService.QueryActivityUserListByOrderIdAsync(orderId);
            return UnaryResult.Succeed(result);
        }
    }
}
